<html>
<head><meta charset="utf-8"><title>Warning on (&amp;T).clone() · t-compiler/wg-diagnostics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/index.html">t-compiler/wg-diagnostics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/Warning.20on.20(.26T).2Eclone().html">Warning on (&amp;T).clone()</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209304734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/Warning%20on%20%28%26T%29.clone%28%29/near/209304734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/Warning.20on.20(.26T).2Eclone().html#209304734">(Sep 07 2020 at 15:00)</a>:</h4>
<p>I just saw someone get bit by this on twitter, I feel like (&amp;T).clone should almost never be used, I know clippy can catch this, but clippy typically happens after the code already compiles, whereas people may hit problems with compilations due to this</p>



<a name="209389649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/Warning%20on%20%28%26T%29.clone%28%29/near/209389649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/Warning.20on.20(.26T).2Eclone().html#209389649">(Sep 08 2020 at 13:59)</a>:</h4>
<p>See also <a href="https://stackoverflow.com/q/46906220/155423">Why does the derived clone() method return a reference? [duplicate]</a> and <a href="https://stackoverflow.com/q/37765586/155423">Why does cloning my custom type result in &amp;T instead of T?</a>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>